package org.hikari.qqbot.xiuxian.command;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;

/**
 * created at 2024-12-25 16:18:01
 *
 * @author yinchao
 * @version 1.0
 **/
@Getter
@Setter
@ToString
public class CommandExecutionInfo {

    /**
     * 任务id
     */
    private String taskId;
    /**
     * 发送的命令文本
     */
    private String command;
    /**
     * 当前用户id
     */
    private Long selfId;
    /**
     * 发送用户id
     */
    private Long userId;
    /**
     * 发送QQ群id
     */
    private Long groupId;
    /**
     * 预计发送时间
     */
    private Date expectSendTime;
    /**
     * 实际发送时间
     */
    private Date actualSendTime;

    public ExecutableCommand toExecutableCommand() {
        return new ExecutableCommand(
                taskId,
                command,
                selfId,
                userId,
                groupId,
                expectSendTime
        );
    }

    public static CommandExecutionInfo from(ExecutableCommand command, Date actualSendTime) {
        CommandExecutionInfo info = new CommandExecutionInfo();
        info.setTaskId(command.getTaskId());
        info.setCommand(command.getCommand());
        info.setSelfId(command.getSelfId());
        info.setUserId(command.getUserId());
        info.setGroupId(command.getGroupId());
        info.setExpectSendTime(command.getSendTime());
        info.setActualSendTime(actualSendTime);
        return info;
    }

}
